<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>带图标的侧边栏菜单</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            display: flex;
        }

        /* 侧边栏样式 */
        .sidebar {
            flex-shrink: 0;
            width: 250px;
            height: 100vh;
            background-color: #2c3e50;
            padding: 20px;
            color: #fff;
            box-sizing: border-box;
            overflow: auto;
        }

        .sidebar-header {
            font-size: 24px;
            margin-bottom: 30px;
            text-align: center;
        }

        .sidebar-menu {
            list-style: none;
            /*当菜单项内容宽度都小于侧边栏时，菜单宽度为侧边栏宽度；
              当有的菜单项内容宽度大于侧边栏时，菜单宽度设为fit-content，使侧边栏产生滚动条防止菜单项显示不全
            */
            width: fit-content;
            min-width: 100%;
        }

        .sidebar-menu li {
            padding: 12px;
            cursor: pointer;
            border-radius: 6px;
        }

        .sidebar-menu li:hover {
            background-color: #34495e;
        }

        .sidebar-menu a {
            color: #fff;
            text-decoration: none;
            display: inline-flex;
            gap: 16px;
            align-items: center;
            white-space: nowrap;
        }

        .fas {
            font-style: normal;
        }

        .fa-home::before {
            content: "🏠";
        }

        .fa-user::before {
            content: "🔍";
        }

        .fa-chart-bar::before {
            content: "👤";
        }

        .fa-cog::before {
            content: "🔔";
        }

        .fa-file::before {
            content: "❤️";
        }

        .fa-envelope::before {
            content: "❓";
        }

        .fa-signout::before {
            content: "📤";
        }

        /* 内容区域样式 */
        .content {
            flex: 1 1 0;
            min-width: 0;
            padding: 20px;
            background-color: #f5f6fa;
            box-sizing: border-box;
            overflow: auto;
        }

        .content h1 {
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="sidebar">
        <div class="sidebar-header">
            <h2>菜单</h2>
        </div>
        <ul class="sidebar-menu">
            <li>
                <a href="#"><i class="fas fa-home"></i>首页</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-user"></i>个人信息</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-chart-bar"></i>这是一条文本内容比较长的菜单</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-cog"></i>设置</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-file"></i>文档</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-envelope"></i>消息</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-signout"></i>退出</a>
            </li>
        </ul>
    </div>

    <div class="content">
        <h1>欢迎来到主页</h1>
        <p style="width: 1200px;">这是一个带图标的侧边栏菜单示例。这是一个带图标的侧边栏菜单示例。这是一个带图标的侧边栏菜单示例。</p>
    </div>
</body>
</html>